package com.liuyi.netty.im.test.lychat.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * sa-token配置
 *
 * @author Mr.Fmy
 * @since 2021/12/25
 */
@Configuration
public class SaTokenConfig implements WebMvcConfigurer {

    public static final String ALL_PATH = "/satoken-all";

    /**
     * 放行接口
     */
    private final String[] excludePath = new String[]{"**" + ALL_PATH + "/**", "**/login/**", "/login/**", ALL_PATH + "/**", "/error"};


    // 注册拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册Sa-Token的路由拦截器
//        registry.addInterceptor(new SaRouteInterceptor((req, res, handler) -> {
//            StpUtil.checkLogin();
//        })).addPathPatterns("/**").excludePathPatterns(excludePath);
    }
}
